package com.zy.cat.common.utils.push;

import java.util.List;

import com.zy.cat.common.utils.HdkAPI;
import com.zy.cat.entity.dev.act.CatDailyDrawResult;
import com.zy.cat.service.impl.AsyncServiceImpl;

public class UmengPushAPI {

	private String appkey = null;
	private String appMasterSecret = null;
	private String timestamp = null;
	private PushClient client = new PushClient();
	
	private static UmengPushAPI instance;
	
	public UmengPushAPI(String key, String secret) {
		try {
			appkey = key;
			appMasterSecret = secret;
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public static UmengPushAPI getInstance() {
		if (instance==null) {
			instance=new UmengPushAPI("5e8ec8a9167eddf8b10001f9", "vp3fnwza12ufpcvineqfnpdlt7ruc6kb");
		}
		return instance;
	}
	
	 public void sendAndroidListcast(String ticker, String title, String text, List<String> tokenList) throws Exception {
	        AndroidListcast listcast = new AndroidListcast(appkey,appMasterSecret);
	        // TODO Set your device token
	        listcast.setDeviceToken("AlfO5lv6hNPneIo6BefYO79feg-CTPyb824op_g1Fpzl");
	        listcast.setTicker("你参与的活动已开奖");
	        listcast.setTitle("开奖了");
	        listcast.setText("你参与的一个抽奖活动正在开奖，请前往开奖");
	        listcast.goAppAfterOpen();
	        listcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
	        // TODO Set 'production_mode' to 'false' if it's a test device.
	        // For how to register a test device, please see the developer doc.
	        listcast.setProductionMode();
	        // Set customized fields
	        listcast.setExtraField("test", "helloworld");
	        listcast.setChannelActivity("your channel activity");
	        listcast.setChannelProperties("abc");
	        client.send(listcast);
	    }
	 
	/*
	 * public static void main(String[] args) { // TODO set your appkey and master
	 * secret here UmengPushAPI demo = new UmengPushAPI("5e8ec8a9167eddf8b10001f9",
	 * "vp3fnwza12ufpcvineqfnpdlt7ruc6kb"); String ticker="你参与的活动已开奖"; String
	 * title="开奖了"; String text="你参与的一个抽奖活动正在开奖，请前往开奖";
	 * demo.sendAndroidListcast(ticker, title, text, tokenList); }
	 */
}
